package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import com.zzyl.vo.NursingPlanVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nursingLevel")
@Api(tags = "护理等级")
public class NursingLevelController {
    @Autowired
    NursingLevelService nursingLevelService;

    @GetMapping("/listAll")
    @ApiOperation("查询所有护理等级")
    public ResponseResult queryAll() {
        List<NursingPlanVo> nursingPlanVoList = nursingLevelService.queryAll();
        return ResponseResult.success(nursingPlanVoList);
    }
    @PostMapping("/insert")
    @ApiOperation("新增护理等级")
    public ResponseResult add(@RequestBody NursingLevelDto nursingLevelDto){
        nursingLevelService.add(nursingLevelDto);
        return ResponseResult.success();
    }
    @GetMapping("/listByPage")
    @ApiOperation("条件分页查询")
    public ResponseResult<PageResponse<NursingLevelVo>> listByPage(String name, @RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize, Integer status){
        PageResponse<NursingLevelVo> result = nursingLevelService.listByPage(name, pageNum, pageSize, status);
        return ResponseResult.success(result);
    }
    @GetMapping("/{id}")
    @ApiOperation("根据id查询")
    public ResponseResult queryById(@PathVariable Long id){
        NursingLevelVo nursingLevelVo =nursingLevelService.queryById(id);
        return ResponseResult.success(nursingLevelVo);
    }
    @PutMapping("/update")
    @ApiOperation("编辑")
    public ResponseResult update(@RequestBody NursingLevelDto nursingLevelDto){
        nursingLevelService.update(nursingLevelDto);
        return ResponseResult.success();
    }
    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除")
    public ResponseResult delete(@PathVariable Long id){
        nursingLevelService.delete(id);
        return ResponseResult.success();
    }
    @PutMapping("/{id}/status/{status}")
    @ApiOperation("启用禁用")
    public ResponseResult statusChange(@PathVariable Long id,@PathVariable Integer status){
        nursingLevelService.statusChange(id,status);
        return ResponseResult.success();
    }


}
